class Solution
{
public:
    bool strongPasswordCheckerII(string password)
    {
        if (password.size() < 8)
        {
            return false;
        }
        char lastChar = -1;
        bool hasLower = false;
        bool hasUpper = false;
        bool hasNumber = false;
        bool hasSpecial = false;
        for (char c : password)
        {
            if (c == lastChar)
            {
                return false;
            }
            lastChar = c;
            if (!hasLower && c >= 'a' && c <= 'z')
            {
                hasLower = true;
            }
            if (!hasUpper && c >= 'A' && c <= 'Z')
            {
                hasUpper = true;
            }
            if (!hasNumber && c >= '0' && c <= '9')
            {
                hasNumber = true;
            }
            if (!hasSpecial && specialChars.count(c))
            {
                hasSpecial = true;
            }
        }
        return hasLower && hasUpper && hasNumber && hasSpecial;
    }

private:
    unordered_set<char> specialChars{'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+'};
};